﻿using System;
using System.Collections;
using System.Collections.Generic;
using TrueSync;

public enum StandardSubitemPositionEnum
{
    OnMyEntity,
    OnRivalsEntity,
    OnTargetPosition,
    OnUseParentPositionX,
    OnUseParentHangpoint,
    OnUseCollisionPosition,
}

public enum StandardSubitemSyncMethodEnum
{
    DontSync,
    SyncPosition,
    SyncAngle,
    SyncBothPositionAndAngle,
}

public class StandardSubitemHangpointDef : HangpointDef
{
    public StandardSubitemSyncMethodEnum StandardSubitemSyncMethod;

    public override void Serialize(EByte ms)
    {
        base.Serialize(ms);
        ms.WriteInt((int)StandardSubitemSyncMethod);
    }

    public override void Deserialize(EByte ms)
    {
        base.Deserialize(ms);
        StandardSubitemSyncMethod = (StandardSubitemSyncMethodEnum)ms.ReadInt();
    }
}

[System.Serializable]
public class LogicStandardSubItemPositionComponent : LogicComponent
{
    public OnUserParentHangpointDef OnUserParentHangpoint;//父子物体位置

    public StandardSubitemPositionEnum StandardSubitemPosition;
    public StandardSubitemHangpointDef Hangpoint;

    bool mIsInit;
    public void Init(LogicEntity LEntity)
    {
        mIsInit = false;
    }

    public void Start()
    {
    }
    

    public void DoUpdate(FP deltaTime)
    {
        if (mIsInit == false)
            return;
    }

    public void Destroy()
    {

    }

    public void Serialize(EByte ms)
    {
        ms.WriteInt((int)StandardSubitemPosition);
        Hangpoint.Serialize(ms);
        OnUserParentHangpoint.Serialize(ms);
    }

    public void Deserialize(EByte ms)
    {
        StandardSubitemPosition = (StandardSubitemPositionEnum)ms.ReadInt();
        Hangpoint = new StandardSubitemHangpointDef();
        Hangpoint.Deserialize(ms);
        OnUserParentHangpoint = new OnUserParentHangpointDef();
        OnUserParentHangpoint.Deserialize(ms);
        mIsInit = true;
    }
}
